set nocount on;


declare @Environment varchar(75)

set @Environment = 'Development'

--Pre-emptive Delete
delete
from
  BIMonitor.WMIQueries
where
  Environment = @Environment



--SQL Server
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'SQL Server','ServerName=\\waBISQL1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Service','waBISQL1','select state from win32_service where name = "MSSQLSERVER"')


--Analysis Services
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'Analysis Services','ServerName=\\waBIOLAP1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Service','waBIOLAP1','select state from win32_service where name = "MSSQLServerOLAPService"')


--Integration Services
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'Integration Services','ServerName=\\waBIETL1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Service','waBIETL1','select state from win32_service where name = "MsDtsServer"')


--Log Drive % Space Free
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'Log Drive % Disk Free','ServerName=\\waBISQL1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Disk Drive','waBISQL1','select PercentFreeSpace from Win32_PerfFormattedData_PerfDisk_LogicalDisk where Name = "C:"')


--Data Drive Free MB
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'Data Drive Free MB','ServerName=\\waBISQL1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Disk Drive','waBISQL1','select FreeMegabytes from Win32_PerfFormattedData_PerfDisk_LogicalDisk where Name = "D:"')


--Operating System Free Memory
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'Operating System Free Memory','ServerName=\\waBISQL1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Memory','waBISQL1','select AvailableMBytes from Win32_PerfFormattedData_PerfOS_Memory')


--Total Processor Utilization %
insert into BIMonitor.WMIQueries(Environment,WMITask,WMIConnectionString,ComponentType,ServerName,WQL)
values(@Environment,'Total Processor Utilization %','ServerName=\\waBISQL1;Namespace=\root\cimv2;UseNtAuth=True;UserName=;',
  'Processor','waBISQL1','select PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor where Name = "_Total"')